fix: preserve inbound qqofficial msg anchor for proactive sends#6856
fix: preserve inbound qqofficial msg anchor for proactive sends#6856jueshali wants to merge 1 commit intoAstrBotDevs:masterfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求旨在解决 Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
_session_last_outbound_message_idcache andremember_session_sent_message_idhelper are currently written but never read; if there’s no planned usage, consider removing them to avoid confusion and keep the adapter’s state minimal. remember_session_message_idnow delegates toremember_session_inbound_message_id, which changes its semantics to inbound-only; if this method is part of a broader adapter interface, it may be worth adding a short comment in-code to clarify that it intentionally represents inbound anchors for proactive sends.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `_session_last_outbound_message_id` cache and `remember_session_sent_message_id` helper are currently written but never read; if there’s no planned usage, consider removing them to avoid confusion and keep the adapter’s state minimal.
- `remember_session_message_id` now delegates to `remember_session_inbound_message_id`, which changes its semantics to inbound-only; if this method is part of a broader adapter interface, it may be worth adding a short comment in-code to clarify that it intentionally represents inbound anchors for proactive sends.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
修复了
qq_official在主动私聊发送场景下msg_id锚点被错误覆盖的问题。此前,适配器会在一次主动发送成功后,将机器人自己发出的消息返回
id写回会话缓存,并在下一次主动发送时继续把它当作msg_id使用。在 QQ Official C2C 场景下,这会导致后续主动发送出现如下报错:请求参数msg_id无效或越权本次修改保证主动发送始终使用“最近一次用户入站消息”的
msg_id作为发送锚点,而不会被机器人自己的出站消息id覆盖。Modifications / 改动点
修改了 astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py
将会话消息缓存拆分为两类:
msg_idid主动发送时仅使用入站消息
msg_id作为发送锚点主动发送成功后,不再用机器人自己的出站消息
id覆盖入站锚点This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
验证步骤:
qq_official机器人配置启动 AstrBot。msg_id。send_by_session链路触发一次主动发送。msg_id越权报错。验证结果:
botpy.errors.ServerError: 请求参数msg_id无效或越权。示例日志: